package com.heima.wemedia.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.mapper.WmChannelMapper;
import com.heima.wemedia.service.WemetiaService;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmNewsMaterialService;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WmChannelServiceImpl extends ServiceImpl<WmChannelMapper, WmChannel> implements WmChannelService {
    @Autowired
    private  WmNewsService wmNewsService;
    @Autowired
    private WmNewsMaterialService wmNewsMaterialService;
    @Autowired
    private WemetiaService wemetiaService;
    @Override
    public ResponseResult submitWmNews(WmNewsDto wmNewsDto) {
//        1.前端提交发布或保存为草稿
        if (wmNewsDto==null)
        {
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_REQUIRE,"缺少参数");
        }

//        2.后台判断请求中是否包含了文章id
        Integer id = wmNewsDto.getId();
        if (id==null)
        {
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_REQUIRE,"缺少参数");

        }
        // 4.如果包含了id，则为修改请求
        if (wmNewsService.getById(id)!=null) {
            //	    4.1 删除该文章与素材的所有关系
            wmNewsService.removeById(id);


        //	    4.2 执行修改操作

        //	    4.3 关联文章内容图片与素材的关系

        //      4.4 关联文章封面图片与素材的关系

        }

//        3.如果不包含id,则为新增

//	    3.1 执行新增文章的操作

//	    3.2 关联文章内容图片与素材的关系

//	    3.3 关联文章封面图片与素材的关系


        return null;
    }
}
